<template>
  <div>
    <!-- 自己调用parent组件 -->
    <Parent :parent="parent.parent" v-if="parent.parent" @btnCallReply="diguiReply"></Parent>
    <div class="parentStyle">
      <div class="postInfo">
        <span class="nickname">{{parent.user.nickname}}</span>
        <span class="date">2小时前</span>
        <div class="btnreply" @click="btnReply">回复</div>
      </div>
      <div class="postContent">{{parent.content}}</div>
    </div>
  </div>
</template>
<script>
export default {
  name: "Parent",
  props: ["parent"],
  methods: {
    btnReply() {
      //这里是直接传递到comment最外层
      this.$emit("btnCallReply", this.parent.id, this.parent.user.nickname);
    },
    diguiReply(id, nickname) {
      //这里是从最底层向上一级parent传递参数
      this.$emit("btnCallReply", id, nickname);
    }
  }
};
</script>
<style lang="less" scoped>
.parentStyle {
  padding: 18px 16px;
  border: 1px solid #d7d7d7;
  border-radius: 6px;
  margin: 0 16px;
  background-color: #eee;
  .postInfo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6.667vw;
    .date {
      flex: 1;
      color: #888;
      font-size: 3.333vw;
      padding-left: 3.889vw;
    }
    .btnreply {
      color: #888;
      font-size: 3.333vw;
    }
    .nickname {
      font-size: 3.889vw;
    }
  }
}
</style>